#include "Thread.hpp"

#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>

using std::cout;
using std::endl;

class Task
{
public:
    void process()
    {
        int cnt = 20;
        srand(time(nullptr));
        while(cnt-- > 0) {
            int num = rand() % 100;
            cout << "sub thread " << pthread_self() << " num: " << num << endl;
            sleep(1);
        }
    }
};

void process()
{
    int cnt = 20;
    srand(time(nullptr));
    while(cnt-- > 0) {
        int num = rand() % 100;
        cout << "sub thread " << pthread_self() << " num: " << num << endl;
        sleep(1);
    }
}

int main()
{
    //Task task;
    //wd::Thread mythread(std::bind(&Task::process, task));
    wd::Thread mythread(process);
    mythread.start();
    mythread.join();
    cout << "main thread exit" << endl;

    return 0;
}

